{% extends "ask/base.html" %}

{% load markup uni_form tagging_tags voting_tags static %}

{% block jsblock %}
{{ block.super }}
{% get_static_prefix as STATIC_PREFIX %}
{% if user_markup == "mrk" %}
<link rel="stylesheet" type="text/css" href="{{STATIC_PREFIX}}js/markitup/skins/simple_small/style.css" />
<link rel="stylesheet" type="text/css" href="{{STATIC_PREFIX}}js/markitup/sets/markdown/style.css" />
<script type="text/javascript" src="{{STATIC_PREFIX}}js/showdown.js"></script>
<script type="text/javascript" src="{{STATIC_PREFIX}}js/markitup/jquery.markitup.js"></script>
<script type="text/javascript" src="{{STATIC_PREFIX}}js/markitup/sets/markdown/set.js"></script>
{% else %}{% if user_markup == "htm" %}
<script type="text/javascript" src="{{STATIC_PREFIX}}js/tiny_mce/jquery.tinymce.js"></script>
{% endif %}{% endif %}

<script language="javascript">
$(document).ready(function()	{
    $('textarea[name="text"]').after($('#iform-cont'));
    {% if user_markup == "mrk" %}
    $('textarea[name="text"]').markItUp(mySimpleMarkdownSettings);
    {% else %}{% if user_markup == "htm" %}
		$('textarea[name="text"]').tinymce({
			// Location of TinyMCE script
			script_url : '{{STATIC_PREFIX}}/js/tiny_mce/tiny_mce.js',
			// General options
			theme : "advanced",
		});
    {% endif %}{% endif %}
});
</script>

{% endblock %}

{% block breadcrumbs %}
{{block.super}} &raquo;  <a href="{{request.path}}">{% if not title %} {{ object.title }}{% else %}{{ title }}{% endif%}</a>  
{% endblock %}

{% block rightcol %}
{% endblock %}

{% block content%}
{{ object.do_view }}
<h1>{% if not title %}{{ object.title }}{% else %}{{ title }}{% endif%}</h1>
<div>
		{% include "object-vote-block.html"%}
	    <div class="question-body">
	    <div class="mrk-text-block">
		{{ object.text|markdown:"extra" }}
		</div>
		{% with "ask_questions_by_tag" as url_name %}
		{% include "tag-list.html" %}
		{% endwith %}
		{% include "object-author-info.html" %}
		<div style="clear:both;"></div>
		</div>
</div>

{% if ans_count %}
{% with object as question %}
<h2 id='answers'>{{ ans_count }} {{ _("Answers") }}</h2>

<div class="split-line"></div>

{% for item in page.object_list %}
{% with item as object %}
<div>
      	<div class="fl" style="width:50px;text-align:center;">
	      <a class="upvote-arrow" title="{{_("I like it")}}" onClick="javascript:{qvote(this, 1);return false;}" href="{% url vote app=object.get_app, model=object.get_model, object_id=object.pk, direction="up" %}">&nbsp;</a><br>
	      {% score_for_object object as score%}
	      <font color="gray" size="6"><b class="qvote-score">{{score.score}}</b></font><br>
	      <a class="downvote-arrow" title="{{_("I didn't like it")}}" onClick="javascript:{qvote(this, -1);return false;}" href="{% url vote app=object.get_app, model=object.get_model, object_id=object.pk, direction="down" %}">&nbsp;</a><br>
	      <br>
	      {% ifequal request.user question.user %}	      
	      <a class="qaccept{{ object.is_accepted }}" onClick="qaccept(this);return false;" href="{% url ask_accept_answer object.pk %}?next={{request.path}}" title="{{_("Accept this answer")}}">&nbsp;</a><br>
	      {% else %}
	      {% if object.is_accepted %}
	      <div class="qaccept{{ object.is_accepted }}" title="{{_("Accepted answer")}}">&nbsp;</div><br>
	      {% endif %}
	      {% endifequal %}
	    </div>
<div >
{{ object.text|markdown:"extra" }}
{% include "object-author-info.html" %}
</div>
<div style="clear:both;"></div>
</div>
{% endwith %}
{% endfor %}

{% include "paginator.html" %}
{% endwith %}
{% endif %}


{% if form %}
<h2>{{_("Your Answer")}}</h2>
{% if not request.user.is_authenticated %}
{{ _("To answer the question you need to be authenticated.") }}
{% endif %}
<form action="" method="POST">
  {% csrf_token %}
{{ form|as_uni_form }}
<input type="submit" value="{{ _("Post Answer") }}">
</form>
{% endif %}

{% endblock %}